package ca.uguu.gamelib.libgdx.concepts;


import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class SpriteScene extends Scene{
	final static private float METRE_SCALE = 2.5f; //The number of metres per pixel/OpenGL unit
	protected OrthographicCamera camera;
	protected SpriteBatch batch;
	
	public SpriteScene(){
		super();
		final float width = Gdx.graphics.getWidth();
		final float height = Gdx.graphics.getHeight();
		
		this.camera = new OrthographicCamera(width, height);
		this.batch = new SpriteBatch();
	}
	
	@Override
	public void dispose(){
		super.dispose();
		this.batch.dispose();
	}
	
	@Override
	public void render(){
		this.render(null);
	}
	
	public void render(Iterable<Sprite> sprites){
		super.render();
		this.camera.update(); //Only if the location was changed
		if(sprites != null){
			this.batch.setProjectionMatrix(this.camera.combined);
			this.batch.begin();
			for(Sprite sprite : sprites){
				sprite.draw(this.batch);
			}
			this.batch.end();
		}
	}
	
	public SpriteBatch getSpriteBatch(){
		return this.batch;
	}
}
